<?php
namespace Company\Controller;
use Think\Controller;
class ExportfileController extends BaseController {
    public function _initialize()
    {
        parent::_initialize();
        $g=session('company');
		C('erp_dbname',$g['db']);
        $db_name=$g['db'];
		//数据库连接基础配置-begin
		C('db_config.DB_TYPE',C('DB_TYPE'));
		C('db_config.DB_HOST',C('DB_HOST'));
		C('db_config.DB_USER',C('DB_USER'));
		C('db_config.DB_PWD',C('DB_PWD'));
		C('db_config.DB_PORT',C('DB_PORT'));
		C('db_config.DB_CHARSET',C('DB_CHARSET'));
		C('db_config.DB_NAME',C('erp_dbname'));
		//数据库连接基础配置-end
    }
	//月度统计
	public function otherfee_statistical(){
		$api_url="http://www.t-cang.com/oms/index.php/Api/ErpApi/otherfee_month_excel";
		$u=M('user');
		$param=I('param.','','trim');
		if(empty($param['username'])){
			$username=session('company.username');
		}else{
			$username=$param['username'];
		}
		$u_info=$u->where(array('username'=>$username))->find();
		
		$push_data['customer']['user_code']=$u_info['user_code'];
		$push_data['customer']['user_key']=$u_info['user_key'];
		
		if(!empty($param['start_time'])){
			$push_data['data']['start_time']=$param['start_time'];
		}
		if(!empty($param['end_time'])){
			$push_data['data']['end_time']=$param['end_time'];
		}
		
		$p=I('p')?I('p'):1;
		$push_data['data']['p']=$p;
		
		$res=push($api_url,$push_data);
		$res=json_decode($res,true);
		
		$listrows=500;
		$count=$res['data']['count_data'][0]['total'];
		$page_nums=$count/$listrows;
		
		$this->assign("page_nums",$page_nums);		
		
		$this->display();
	}
	//月度统计
	public function month_statistical(){
		$api_url="http://www.t-cang.com/oms/index.php/Api/ErpApi/count_month";
		$u=M('user');
		$param=I('param.','','trim');
		if(empty($param['username'])){
			$username=session('company.username');
		}else{
			$username=$param['username'];
		}
		$u_info=$u->where(array('username'=>$username))->find();
		
		$push_data['customer']['user_code']=$u_info['user_code'];
		$push_data['customer']['user_key']=$u_info['user_key'];
		
		if(!empty($param['start_time'])){
			$push_data['data']['start_time']=$param['start_time'];
		}
		if(!empty($param['end_time'])){
			$push_data['data']['end_time']=$param['end_time'];
		}
		
		$p=I('p')?I('p'):1;
		$push_data['data']['p']=$p;
		
		$res=push($api_url,$push_data);
		$res=json_decode($res,true);
		
		
		$listrows=500;
		$count=$res['data']['count_data'][0]['total'];
		$page_nums=$count/$listrows;
		
		$this->assign("page_nums",$page_nums);								
		$this->display();
	}
	
	
}